clear
set more off
set matsize 2000
set scheme modern

*	Change CD
*	global root         	"..."
	global raw				="$root/raw"
	global output			="$root/output"
	}

	
use "$raw/prussia_final", clear


********************************************************************************
*Figure 2a
********************************************************************************

reg 	s_conservatives s_bigfarms 	s_agri 	s_prot s_urban 	s_german log_pop i.province_id  	i.t if ostelbien==1, cluster(district_name)
	local coef_main=round(_b[s_bigfarms],.001)
	local t = _b[s_bigfarms]/_se[s_bigfarms]
	local t_round = round(`t',.001)
	local p =2*ttail(e(df_r),abs(`t')) // computes p-value

	if `p'<.01 {
		local signstars = "***"
	}
	else if `p'>=.01 & `p'<.05 {
		local signstars = "**"
	}
	else if `p'>=.05 & `p'<.1 {
		local signstars = "*"
	}
	else if `p'>= .1 {
		local signstars = ""
	}
	
	local string_main= "{&beta}="+"`coef_main'"+"`signstars'"
	display "string_main"

	local t_main = "t=`t_round'"
	display "t_main"

local ytitle "Votes conservative (in %)"
local xtitle "Large landowners (in %)"	
binscatter s_conservatives s_bigfarms if ostelbien==1, n(60) control(s_agri s_prot s_urban s_german log_pop i.t i.province_id) ytitle(`ytitle') xtitle(`xtitle') text(46 3 "`string_main'", color(black) place(e)) text(44 3 "`t_main'", color(black) place(e)) 
graph export "$output/figure2a.pdf", replace

********************************************************************************
*Figure 2b
********************************************************************************

reg 	s_conservatives s_nobel_area 	s_agri 	s_prot s_urban 	s_german log_pop i.province_id  	i.t if ostelbien==1, cluster(district_name)
	local coef_main=round(_b[s_nobel_area],.001)
	local t = _b[s_nobel_area]/_se[s_nobel_area]
	local t_round = round(`t',.001)
	local p =2*ttail(e(df_r),abs(`t')) // computes p-value

	if `p'<.01 {
		local signstars = "***"
	}
	else if `p'>=.01 & `p'<.05 {
		local signstars = "**"
	}
	else if `p'>=.05 & `p'<.1 {
		local signstars = "*"
	}
	else if `p'>= .1 {
		local signstars = ""
	}
	
	local string_main= "{&beta}="+"`coef_main'"+"`signstars'"
	display "string_main"

	local t_main = "t=`t_round'"
	display "t_main"

local ytitle "Votes conservative (in %)"
local xtitle "Land owned by nobility (in %)"	
binscatter s_conservatives s_nobel_area if ostelbien==1, n(60) control(s_agri s_prot s_urban s_german log_pop i.t i.province_id) ytitle(`ytitle') xtitle(`xtitle') text(46 40 "`string_main'", color(black) place(e)) text(44 40 "`t_main'", color(black) place(e)) 
graph export "$output/figure2b.pdf", replace




********************************************************************************
*Figure4a 
********************************************************************************

reg 	e_turnout s_bigfarms 	s_agri 	s_prot s_urban 	s_german log_pop i.province_id  	i.t if ostelbien==1, cluster(district_name)
	local coef_main=round(_b[s_bigfarms],.001)
	local t = _b[s_bigfarms]/_se[s_bigfarms]
	local t_round = round(`t',.001)
	local p =2*ttail(e(df_r),abs(`t')) // computes p-value

	if `p'<.01 {
		local signstars = "***"
	}
	else if `p'>=.01 & `p'<.05 {
		local signstars = "**"
	}
	else if `p'>=.05 & `p'<.1 {
		local signstars = "*"
	}
	else if `p'>= .1 {
		local signstars = ""
	}
	
	local string_main= "{&beta}="+"`coef_main'"+"`signstars'"
	display "string_main"

	local t_main = "t=`t_round'"
	display "t_main"

local ytitle "Tunrout (in %)"
local xtitle "Large landowners (in %)"	
binscatter e_turnout s_bigfarms if ostelbien==1, n(60) control(s_agri s_prot s_urban s_german log_pop i.t i.province_id) ytitle(`ytitle') xtitle(`xtitle') text(74 3 "`string_main'", color(black) place(e)) text(73 3 "`t_main'", color(black) place(e)) 
graph export "$output/figure4a.pdf", replace

sum s_bigfarms
di  1.637127 *r(sd)
sum e_turnout
di 1.2658599 / r(sd)



********************************************************************************
*Table 2
********************************************************************************

use "$raw/prussia_migration", clear

gen east = 0
foreach number in 1 4 12 5 6 9 8 {
	replace east = 1 if province_id==`number'
}


replace s_agri = s_agri * 100

eststo mig1: reg av_migt s_bigfarms s_agri  i.t 				if east==1	, cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm


eststo mig2: reg av_migt s_bigfarms s_agri  i.province_id i.t 	if east==1	, cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local RegionFE "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm


eststo mig3: reg av_migt s_bigfarms s_agri  i.t								, cluster(district_name)
estadd local YearFE "\checkmark"
estadd local Control "\checkmark"
estadd local All "\checkmark"
quietly: estadd ysumm


eststo mig4: reg av_migt s_bigfarms s_agri  i.province_id i.t				, cluster(district_name)
estadd local YearFE "\checkmark"
estadd local RegionFE "\checkmark"
estadd local Control "\checkmark"
estadd local All "\checkmark"
quietly: estadd ysumm


local titles " Dep. var. & \multicolumn{4}{c}{Yearly net-migration (in \%)} \\" 

#delimit ;
estout mig1 mig2 mig3 mig4 using "$output/tab2.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_bigfarms)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd YearFE RegionFE Control East All r2  N , fmt(%9.2f %9.2f  %~3s %~3s %~3s %~3s  %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Year FE" "Province FE" "Control" "Sample: East Elbia" "Sample: Prussia" "R-squared"  "Observations" ))
	mlabels("" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xccccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-5} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		



********************************************************************************
*Appendix Table A1, part for Prussia
********************************************************************************
use "$raw/prussia_final", clear

sum  s_conservatives e_turnout, d
sum s_nobel_area if t==1871, d


	
********************************************************************************
*Appendix Table A2
********************************************************************************
eststo kaiser_iv_1: ivreg2 	s_conservatives (s_bigfarms = s_area_iv) s_agri 	s_prot s_urban s_german log_pop					i.t if ostelbien==1, cluster(district) first
mat fstat=e(first)
estadd scalar f_sec = fstat[4,1]
estadd local YearFE "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo kaiser_iv_2: ivreg2 	s_conservatives (s_bigfarms = s_area_iv) s_agri 	s_prot s_urban s_german log_pop	 i.province_id	i.t if ostelbien==1, cluster(district) first
mat fstat=e(first)
estadd scalar f_sec = fstat[4,1]
estadd local YearFE "\checkmark"
estadd local Control "\checkmark"
estadd local RegionFE "\checkmark"
quietly: estadd ysumm


eststo kaiser_iv_3: reg 	s_conservatives s_bigfarms  s_agri 	s_prot s_german log_pop	s_urban					i.t if ostelbien==1, cluster(district) 
estadd local YearFE "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo kaiser_iv_4: reg 	s_conservatives s_bigfarms  s_agri 	s_prot s_german log_pop	s_urban i.province_id	i.t if ostelbien==1, cluster(district) 
estadd local YearFE "\checkmark"
estadd local Control "\checkmark"
estadd local RegionFE "\checkmark"
quietly: estadd ysumm

local titles " Dep. var. & \multicolumn{4}{c}{Votes Conservatives (in \%)} \\ & \multicolumn{2}{c}{IV} & \multicolumn{2}{c}{OLS} \\" 

#delimit ;
estout kaiser_iv_1 kaiser_iv_2 kaiser_iv_3 kaiser_iv_4   using "$output/appendix_tab02.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep ( s_bigfarms )
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd f_sec YearFE RegionFE Control   r2  N , fmt(%9.2f %9.2f %9.2f %~3s %~3s %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "F-statistics" "Year FE" "Province FE" "Further controls"  "R-squared"  "Observations" ))
	mlabels("" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-5} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		
	


********************************************************************************
*Appendix Table A3
********************************************************************************
eststo farms1: reg s_conservatives s_bigfarms s_agri s_prot s_urban s_german log_pop i.t 					if ostelbien == 1, cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo farms2: reg s_conservatives s_bigfarms s_agri s_prot s_urban s_german log_pop i.t i.province_id 		if ostelbien == 1, cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo farms3: reg s_conservatives s_bigfarms s_agri s_prot s_urban s_german log_pop i.t i.province_id 						, cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local All "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo farms4: reg s_conservatives s_nobel_area s_agri s_prot s_urban s_german log_pop i.t 					if ostelbien == 1, cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo farms5: reg s_conservatives s_nobel_area s_agri s_prot s_urban s_german log_pop i.t i.province_id 	if ostelbien == 1, cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

local titles " Dep. var. & \multicolumn{5}{c}{Votes Conservatives (in \%)} \\" 

#delimit ;
estout farms1 farms2 farms3 farms4 farms5  using "$output/appendix_tab03.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_bigfarms s_nobel_area)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd YearFE RegionFE Control East All r2  N , fmt(%9.2f %9.2f  %~3s %~3s %~3s %~3s  %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Year FE" "Province FE" "Further controls" "Sample: East Elbia" "Sample: Prussia" "R-squared"  "Observations" ))
	mlabels("" "" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xccccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-6} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		


********************************************************************************
*Appendix Table A8
********************************************************************************

eststo turnout1: reg e_turnout s_bigfarms s_agri s_prot s_urban s_german log_pop  		i.t						if ostelbien==1				, cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo turnout2: reg e_turnout s_bigfarms s_agri s_prot s_urban s_german log_pop  		i.t 	i.province_id 	if ostelbien==1				, cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo turnout3: reg e_turnout s_bigfarms s_agri s_prot s_urban s_german log_pop  		i.t 	i.province_id								, cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local All "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo turnout4: reg e_turnout s_nobel_area s_agri s_prot s_urban s_german log_pop  	i.t						if ostelbien==1				, cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo turnout5: reg e_turnout s_nobel_area s_agri s_prot s_urban s_german log_pop  	i.t 	i.province_id 	if ostelbien==1				, cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm


local titles " Dep. var. & \multicolumn{5}{c}{Turnout (in \%)} \\" 


#delimit ;
estout turnout1 turnout2 turnout3  turnout4 turnout5   using "$output/appendix_tab08.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_bigfarms  s_nobel_area)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd YearFE RegionFE Control East All r2  N , fmt(%9.2f %9.2f  %~3s %~3s %~3s  %~3s %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Year FE" "Province FE" "Further controls" "Sample: East Elbia" "Sample: Prussia" "R-squared"  "Observations" ))
	mlabels("" "" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-6} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		


********************************************************************************
*Appendix Table A12
********************************************************************************

foreach year in 1871 1874 1877 1878 1881 1884 1887 1890 1893 1898 1903 1907 1912 {
eststo reg`year': reg s_conservatives s_bigfarms s_agri s_prot s_urban s_german log_pop 	i.province_id			if ostelbien == 1 & t==`year', cluster(district_name)
estadd local Controls "\checkmark"
estadd local RegionFE "\checkmark"
quietly: estadd ysumm
}

local titles " & 1871 & 1874 & 1877 & 1878 & 1881 & 1884 & 1887 & 1890 & 1893 & 1898 & 1903 & 1907 &  1912\\" 
#delimit ;
estout reg1871 reg1874 reg1877 reg1878 reg1881 reg1884 reg1887 reg1890 reg1893 reg1898 reg1903 reg1907 reg1912   using "$output/appendix_tab12.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep ( s_bigfarms)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd Controls RegionFE r2  N , fmt(%9.2f %9.2f %9.2f %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Controls" "Province FE" "R-squared"  "Observations" ))
	mlabels("" "" "" "" "" "" "" "" "" "" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xccccccccccccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-14} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		

	
********************************************************************************
*Appendix Table A15
********************************************************************************
label var log_estates "Estates (in log)"
label var s_superbig "Land owned by very large farmers"
label var landgini "Land inequality (gini)"
	
eststo farms1: reg s_conservatives s_bigland s_agri s_prot s_urban s_german log_pop i.t 					if ostelbien == 1, cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo farms2: reg s_conservatives s_bigland s_agri s_prot s_urban s_german log_pop i.t i.province_id 		if ostelbien == 1, cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo farms3: reg s_conservatives log_estates s_agri s_prot s_urban s_german log_pop i.t 									if ostelbien == 1 & s_bigland!=., cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo farms4: reg s_conservatives log_estates s_agri s_prot s_urban s_german log_pop i.t i.province_id 					if ostelbien == 1 & s_bigland!=., cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm


eststo farms5: reg 	s_conservatives s_superbig 	s_agri 	s_prot s_urban 	s_german log_pop i.t 								if ostelbien==1 & s_bigland!=., cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo farms6: reg 	s_conservatives s_superbig 	s_agri 	s_prot s_urban 	s_german log_pop i.t 	i.province_id  				if ostelbien==1 & s_bigland!=., cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

replace landgini = landgini*100

eststo farms7: reg 	s_conservatives landgini 	s_agri 	s_prot s_urban 	s_german log_pop i.t 								if ostelbien==1 & s_bigland!=., cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo farms8: reg 	s_conservatives landgini 	s_agri 	s_prot s_urban 	s_german log_pop i.t 	i.province_id  				if ostelbien==1 & s_bigland!=., cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm


local titles " Dep. var. & \multicolumn{8}{c}{Votes Conservatives (in \%)} \\" 

#delimit ;
estout farms1 farms2 farms3 farms4 farms5 farms6 farms7 farms8  using "$output/appendix_tab15.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_bigland log_estates s_superbig landgini)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd YearFE RegionFE Control East r2  N , fmt(%9.2f %9.2f  %~3s %~3s %~3s   %~3s   %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Year FE" "Province FE" "Further controls" "Sample: East Elbia" "R-squared"  "Observations" ))
	mlabels("" "" "" "" "" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccccccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-9} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		
	
********************************************************************************
*Appendix Table 16
********************************************************************************

eststo sample1: reg s_conservatives s_bigfarms s_agri s_prot s_urban s_german log_pop i.t i.province_id if ostelbien==1					, cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo sample2: reg s_conservatives s_bigfarms s_agri s_prot s_urban s_german log_pop i.t i.province_id 								, cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local All "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo sample3: reg s_conservatives s_bigfarms s_agri s_prot s_urban s_german log_pop i.t i.province_id 	if ostelbien==1 & outlier==0					, cluster(district_name)
estadd local RegionFE 	"\checkmark"
estadd local YearFE 	"\checkmark"
estadd local Outlier	"\checkmark"
estadd local Control 	"\checkmark"
quietly: estadd ysumm

local titles " Dep. var. & \multicolumn{3}{c}{Votes Conservatives (in \%)} \\" 

#delimit ;
estout sample1 sample2 sample3 using "$output/appendix_tab16.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_bigfarms)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd YearFE RegionFE Control East All Outlier r2  N , fmt(%9.2f %9.2f  %~3s %~3s %~3s %~3s %~3s %~3s  %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Year FE" "Province FE" "Further controls" "Sample: East Elbia" "Sample: Prussia" "Sample: Without outliers" "R-squared"  "Observations" ))
	mlabels("" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-4} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		


********************************************************************************
*Appendix Table A18
********************************************************************************

eststo productivity1: reg 	s_conservatives s_bigfarms 					s_agri 	s_prot s_urban 	s_german log_pop   					i.t if ostelbien==1, cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo productivity2: reg 	s_conservatives s_bigfarms avg_suitability	s_agri 	s_prot s_urban 	s_german log_pop 				 	i.t if ostelbien==1, cluster(district_name)
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo productivity3: reg 	s_conservatives s_bigfarms 					s_agri 	s_prot s_urban 	s_german log_pop i.province_id  	i.t if ostelbien==1, cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

eststo productivity4: reg 	s_conservatives s_bigfarms avg_suitability	s_agri 	s_prot s_urban 	s_german log_pop i.province_id  	i.t if ostelbien==1, cluster(district_name)
estadd local RegionFE "\checkmark"
estadd local YearFE "\checkmark"
estadd local East "\checkmark"
estadd local Control "\checkmark"
quietly: estadd ysumm

local titles " Dep. var. & \multicolumn{4}{c}{Votes Conservatives (in \%)} \\" 

#delimit ;
estout productivity1 productivity2 productivity3 productivity4 using "$output/appendix_tab18.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_bigfarms avg_suitability)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd YearFE RegionFE Control East All r2  N , fmt(%9.2f %9.2f  %~3s %~3s %~3s  %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Year FE" "Province FE" "Further controls" "Sample: East Elbia" "R-squared"  "Observations" ))
	mlabels("" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-5} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		

